package com.hfzy.ihk.web.linkcall.conf;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

@Configuration
@Slf4j
@Order(99)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    /**
     * 忽略静态文件
     */
    @Override
    public void configure(WebSecurity web) throws Exception {
        web.ignoring().antMatchers("/frame/**", "/images/**", "/css/**", "/js/**", "/video/**", "/**/favicon.ico");
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        /**
         * 注：放开的访问的路径
         * 目前用户权限是通过切面控制，放开的访问是没有经过用户的校验，所以无法取到对应的userId 【即是无法对访问接口进行查询权限的控制】
         * 如：需要达到控制用户权限效果 --》 则接口处带上访问的userId
         *     目前没有传该参数，则不作数据权限控制 【即是可见所有】
         * */
        //放开该路径
        http.requestMatchers().antMatchers("/linkageCall/getPageckageIdsByVo/**",
                "/linkageCall/saveLinkCallTask/**","/linkageCall/getVoiceMapByPackageId/**","/linkageCall/test/**","/knowledgeBase/updateKnowledgeBaseResultVo/**","/flowConfig/updateFlowStepRecordFileUrl/**").and().csrf().disable().authorizeRequests().anyRequest()
                .permitAll(); //其他所有需要验证
    }
}
